package com.wx.mapper;

// mapper类访问数据库

import com.wx.entity.Admin;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AdminMapper {

    /*根据管理员username查询*/
    @Select("select * from admin where username = #{username}")
    Admin getByUsername(String username);

    /*插入管理员数据*/
    @Insert("insert into " +
            "admin(username,password,is_frozen,create_time,create_user,update_user) " +
            "values(#{username},#{password},#{isFrozen},#{createTime},#{createUser},#{updateUser})")
    Integer save(Admin admin);

    @Select("select * from admin")
    List<Admin> getAdminList();

    /*传入id，更新is_frozen, update_user*/
    @Update("update admin set is_frozen = #{isFrozen}, update_user = #{updateUser} where id = #{id}")
    Integer update(Admin admin);
}
